package com.bestcem.xm.txtanls.controller.vo;

import com.bestcem.xm.txtanls.grpc.service.param.PageParam;
import com.bestcem.xm.txtanls.service.dto.PageResultDTO;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 返回前端分页数据DTO
 *
 * @author XiaoYunSong <ys.xiao@idiaoyan.com>
 * @version v2.0
 * @date 2021/8/5 17:56
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class PageResponseVO<T> {
    /**
     * 分页页号
     */
    @JsonProperty(value = "page")
    @ApiModelProperty(value = "分页页号")
    private Integer page;

    /**
     * 分页大小
     */
    @JsonProperty(value = "rowsPerPage")
    @ApiModelProperty(value = "分页大小")
    private Integer size;

    /**
     * 记录总数
     */
    @JsonProperty(value = "total_count")
    @ApiModelProperty(value = "记录总数")
    private Long total;

    /**
     * 分页数据
     */
    @JsonProperty(value = "rows")
    @ApiModelProperty(value = "分页数据")
    private List<T> data;

    /**
     * 话题信息展示，原话查询接口使用
     */
    @JsonProperty(value = "topic_info")
    @ApiModelProperty(value = "话题信息展示")
    private String topicInfo;

    public PageResponseVO(PageParam pageParam, PageResultDTO<T> pageResultDTO) {
        this.page = pageParam.getPage();
        this.size = pageParam.getSize();
        this.total = pageResultDTO.getTotal();
        this.data = pageResultDTO.getData();
    }

    public PageResponseVO(PageParam pageParam, PageResultDTO<T> pageResultDTO, String topicInfo) {
        this.page = pageParam.getPage();
        this.size = pageParam.getSize();
        this.total = pageResultDTO.getTotal();
        this.data = pageResultDTO.getData();
        this.topicInfo = topicInfo;
    }
}
